<?php require_once("../../includes_view/header.php"); ?>
<?php 
	$acao = "GRID"; 
	require_once("regras/controlador/lojaController.php"); 
?>
<script type="text/javascript">
	function addLoja(){
		window.location = "<?php echo $url ?>/modulo/loja/loja-cadastrar.php";
	}
	
	function atualizar(id){
		window.location = "<?php echo $url ?>/modulo/loja/loja-atualizar.php?codigo="+id;
	}
</script>
<div id="sistema">
	<div id="migalhas">
    	<a class="mig1">Cadastro</a>
      	<a class="mig2">Loja</a>    	
    </div>
    <div id="pesquisa"></div>
    <br>
    <?php if(isset($class) and isset($mensagem)){ ?>  
    <div id="mensagens" class="<?=$class?>"><?php echo $mensagem; ?></div>    
    <?php } ?>
    <div id="grid">
    	<div id="add-novo"><input type="button" name="addNovo" id="addNovo" value="Adicionar novo" class="button" onClick="addLoja()"></div>
        <table>
        	<thead>
            	<tr>
                    <td>Empresa</td>
                    <td>Responsável</td>
                    <td>CPF/CNPJ</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </thead>
            <tbody>
            	<?php foreach($lojas as $loja){ $i=0;  ?>
            	<tr>
                    <td><?=utf8_encode($loja["empresa"])?></td>
                    <td><?=utf8_encode($loja["nome"])?></td>
                    <td><?=$loja["cpfCnpj"]?></td>
                    <td><input type="submit" name="btnAtualizar_<?=$i?>" id="btnAtualizar_<?=$i?>" value="atualizar" class="button" onClick="atualizar('<?=$loja["id"]; ?>')"></td>
                    <td><input type="submit" name="btnExcluir_<?=$i?>" id="btnExcluir_<?=$i?>" value="excluir" class="button"></td>
                </tr>   
                <?php $i++;  }?>            
            </tbody>
            <tfoot>
            	<tr>
                    <td>Empresa</td>
                    <td>Responsável</td>
                    <td>CPF/CNPJ</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </tfoot>
        </table>
    </div>
</div>
<?php require_once("../../includes_view/footer.php"); ?>